package ysc.cqnu.operdb.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ysc.cqnu.operdb.entity.ResultData;
import ysc.cqnu.operdb.entity.ResultDrawing;
import ysc.cqnu.operdb.entity.Roughsketch;
import ysc.cqnu.operdb.mapper.DrawingMapper;
import ysc.cqnu.operdb.service.CheckDrawingInfoService;

import java.util.ArrayList;
import java.util.List;

@Service
public class CheckDrawingInfoServiceImpl implements CheckDrawingInfoService {
    @Autowired
    private ResultData resultData;
    @Autowired
    private DrawingMapper drawingMapper;
    @Autowired
    private Roughsketch roughsketch;
    @Override
    public ResultData checkDrawingInfoService(String drawname,String renwu,String yongtu,String juti ,String uploader,String uploadDate) {
        try {
            roughsketch = drawingMapper.chazhaoDrawingInfo(drawname,renwu,yongtu,juti,uploader,uploadDate);
            if(roughsketch!=null){
                int count = drawingMapper.count();
                int site = drawingMapper.drawingInfoSite(String.valueOf(roughsketch.getId()));
                roughsketch.Count=String.valueOf(count);
                roughsketch.site=String.valueOf(site);
                resultData.flag="CheckSuccess";
                resultData.data=roughsketch;
                return resultData;
            }
            else {
                resultData.flag="DrawingInfoNoFind";
                resultData.data=null;
                return resultData;
            }
        }catch (Exception e){
            resultData.flag="CheckFail";
            resultData.data=null;
            return resultData;
        }
    }
}
